package com.tuniu.agents.common.service;

import com.tuniu.agents.common.dto.ChatRecordQueryDTO;
import com.tuniu.agents.common.pojo.ChatRecord;
import org.springframework.data.domain.Page;

import java.util.List;
import java.util.Map;


/**
 * Chat Record Service
 */
public interface ChatRecordService {

    /**
     * Get the user's historical conversation list
     * Returns the initial request of each conversation
     * @return Page of ChatRecord
     */
    Page<ChatRecord> getUserConversationsList(ChatRecordQueryDTO dto);

    Page<ChatRecord> getChatRecordsPageByDTO(ChatRecordQueryDTO dto);

    List<ChatRecord> getChatRecordsByDTO(ChatRecordQueryDTO dto);

    ChatRecord savePrimaryResponse(String userId, String conversationId, String requestId, String responseId, String content, Integer isDeleted);

    ChatRecord saveRequest(String conversationId, String userId, String requestId, String responseId, String content, Integer isDeleted);

    List<ChatRecord> getConversationHistory(String conversationId);

    /**
     * Get the conversation list by conversation ID and message type
     * @param conversationId
     * @param messageType
     * @return List of ChatRecord
     */
    List<ChatRecord> findByConversationIdAndMessageTypeOrderByAddTimeDesc(String conversationId, Integer messageType);

    Map<String, Object> parseContent(String content);

    ChatRecord saveSecondaryResponse(String requestId, String responseId, String parentResponseId, String content, Integer isDeleted);

    /**
     * Verify if there are records under member id and conversation id
     * @return ChatRecord
     */
    ChatRecord getRecordOnce(String conversationId, String userId);

    List<ChatRecord> findByConversationIdsAndMessageType(List<String> conversationIds, Integer messageType);
}
